define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'union/hostshare/index',
                    table: 'guild_host_account_daily',
                },
                commonSearch: true,
                searchFormVisible: true,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: true,
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                columns: [
                    [
                        {
                            field: 'dt',
                            title: __('日期'),
                            formatter: Table.api.formatter.datetime, datetimeFormat:"YYYYMMDD",
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                        },
                        {field: 'guild_name', title: __('名称'),operate: false},
                        {field: 'guild_manage_id', title: __('名称'),formatter: Table.api.formatter.normal,searchList:select,visible:false },
                        {field: 'user_profile_id', title: __('用户ID')},
                        {field: 'nick_name', title: __('用户昵称')},

                        {field: 'voice_turnover', title: __('语音总流水'), operate: false},
                        {field: 'video_turnover', title: __('视频总流水'), operate: false},
                        {field: 'gift_turnover', title: __('普通礼物总流水'), operate: false},
                        {field: 'free_turnover', title: __('福利总流水'), operate: false},
                        {field: 'msg_turnover', title: __('私信总流水'), operate: false},
                        // {field: 'video_share_income', title: __('女用户视频分成'), operate: false},
                        // {field: 'voice_share_income', title: __('女用户语音分成'), operate: false},
                        {field: 'total_turnover', title: __('用户总流水'), operate: false},
                        {field: 'host_share', title: __('用户分成比例'), operate: false},
                        {field: 'total_share_income', title: __('用户总分成'), operate: false},
                        {field: 'binded_at', title: __('签约时间'), operate: false},
                        {field: 'last_online_at', title: __('最后登陆时间'), operate: false},
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});